home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_8 / issue_07 / std / !STDFinder / c / delete < prev    next >
Encoding:
Text File  |  1993-03-08  |  884 b   |  42 lines

  1. #include "stdio.h"
  2. #include "stdlib.h"
  3. #include "string.h"
  4. #include "ctype.h"
  5. #include "werr.h"
  6. #include "bbc.h"
  7.  
  8. #define mtnl   50
  9. #define mcl     8
  10.  
  11. extern struct std {
  12.   char town[mtnl];
  13.   char code[mcl];
  14.   struct std *next;
  15.   struct std *previous;
  16.   } *stdstart,*stdlast;  
  17.  
  18. extern int modified;
  19.  
  20. void delete_entry(char *town,char *code)
  21. {
  22. struct std *stdnode;
  23. stdnode = stdstart;
  24.  
  25. while (stdnode) {
  26.   if (!strcmp(stdnode->town,town)) { /* do an exact match */
  27.   if (!strcmp(stdnode->code,code)) { /* if here then is a match */
  28.     if (stdnode->previous) stdnode->previous->next = stdnode->next;
  29.       else { /* new first item */
  30.         stdstart = stdnode->next;
  31.         if (stdstart) stdstart->previous = NULL;
  32.       }
  33.     if (stdnode->next) stdnode->next->previous = stdnode->previous;
  34.     free (stdnode);
  35.     }
  36.   }
  37.   stdnode = stdnode->next;
  38.   }
  39.   modified++;
  40.   bbc_vdu(7);
  41. }
  42.